import java.util.Scanner;

public class StringTest6 {
    public static void main(String[] args) {
        //键盘录入金额
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入金额：");
        int money = sc.nextInt();
        //定义一个空字符串来存储金额的大写
        String result = "";
        //得到金额的各位数字
        while (true){
            if(money == 0){
                break;
            }
            int ge = money % 10;
            money = money / 10;
            String a = toUpperCase(ge);
            result = a + result;
        }
        System.out.println(result);
        //在大写的金额前面补零
        String newResult = addZero(result);
        System.out.println(newResult);
        //把金额的单位也插入
        String newResult1 = addUnit(newResult);
        System.out.println(newResult1);
    }
    /*===============================================方法区==============================================*/
    //定义方法，把金额转换为大写
    public static String toUpperCase(int money){
        //定义数组，存储大写数字
        String[] arr = {"零","壹","贰","叁","肆","伍","陆","柒","捌","玖"};
        String a = arr[money];
        return a;
    }
    //定义方法在大写的金额前面补零,最后补成7位
    public static String addZero(String str){
        int count = 7-str.length();
        //定义字符串用来补零;
        for(int i = 0; i < count;i++){
            str = "零" + str;
        }
        return str;
    }
    //定义方法，把金额的单位也插入
    public static String addUnit(String str){
        String[] arr = {"佰","拾","万","仟","佰","拾","元"};
        //定义字符串用来存储结果
        String result = "";
        for(int i = 0; i < str.length();i++){
            char c = str.charAt(i);
            result = result + c + arr[i];
        }
        return result;
    }
}
